<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('订单详情列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <!--<li>-->
                        <!--<label>订单ID：</label>-->
                        <!--<input type="hidden" name="memberId"  th:value="${member.id}"/>-->
                        <!--</li>-->
                        <!--<li>-->
                        <!--<label>商品ID：</label>-->
                        <input type="hidden" value="0" name="status"/>
                        <input type="hidden" value="0" name="overdue"/>
                        <!--</li>-->
                        <li>
                        <label>优惠券名称：</label>
                        <input type="text" name="name"/>
                        </li>
                        <!--<li>-->
                            <!--<label>评价状态：</label>-->
                            <!--&lt;!&ndash;<input type="text" name="coment"/>&ndash;&gt;-->
                            <!--<select name="coment" th:with="type=${@dict.getType('order_coment')}">-->
                                <!--<option value="">所有</option>-->
                                <!--<option th:each="dict : ${type}" th:text="${dict.dictLabel}"-->
                                        <!--th:value="${dict.dictValue}"></option>-->
                            <!--</select>-->
                        <!--</li>-->
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <!--<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="mall:orderDetail:add">-->
            <!--<i class="fa fa-plus"></i> 添加-->
            <!--</a>-->
            <!--<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="mall:orderDetail:edit">-->
            <!--<i class="fa fa-edit"></i> 修改-->
            <!--</a>-->
            <!--<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="mall:orderDetail:remove">-->
            <!--<i class="fa fa-remove"></i> 删除-->
            <!--</a>-->
            <!--<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="mall:orderDetail:export">-->
            <!--<i class="fa fa-download"></i> 导出-->
            <!--</a>-->
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('mall:orderDetail:edit')}]];
    var removeFlag = [[${@permission.hasPermi('mall:orderDetail:remove')}]];
    var comentDatas  = [[${@dict.getType('coupon_type')}]];
    var prefix = ctx + "system/coupon/coupon";

    $(function() {
        var options = {
            url: prefix+"/list" ,
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "优惠券详情",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: 'ID',
                    visible: false
                },
                {
                    field: 'name',
                    title: '名称'
                },
                {
                    field: 'type',
                    title: '类型',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(comentDatas, value);
                    }
                },
                {
                    field: 'useCondition',
                    title: '使用条件'
                },
                {
                    field: 'price',
                    title: '免减金额'
                }
                ,
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="sendCoupon(\'' + row.id + '\')"><i class="fa fa-edit"></i>发券</a>');
                        return actions.join('');
                    }
                }
            ]
        };
        $.table.init(options);
    });
    
    function sendCoupon(id) {

        layer.confirm('确认发券吗',{
            shade:[0.5,'#000'],
            shift:1,
            shadeClose:true,
            content:"<div class=\"radio-box\">" +
            "                    <input id='sendPost_0' type=\"radio\" name=\"sendPost\" value=\"客户关系部\" checked='checked'>" +
            "                    <label for=\"sendPost_0\">客户关系部</label>" +
            "                </div>"+
            "<div class=\"radio-box\">" +
            "                    <input id='sendPost_1' type=\"radio\" name=\"sendPost\" value=\"销售部\">" +
            "                    <label for=\"sendPost_1\">销售部</label>" +
            "                </div>"+
            "<div class=\"radio-box\">" +
            "                    <input id='sendPost_2' type=\"radio\" name=\"sendPost\" value=\"保险部\">" +
            "                    <label for=\"sendPost_2\">保险部</label>" +
            "                </div>"+
            "<div class=\"radio-box\">" +
            "                    <input id='sendPost_3' type=\"radio\" name=\"sendPost\" value=\"售后部\">" +
            "                    <label for=\"sendPost_3\">售后部</label>" +
            "                </div>"+
            "<div class=\"radio-box\">" +
            "                    <input id='sendPost_4' type=\"radio\" name=\"sendPost\" value=\"保险理赔部\">" +
            "                    <label for=\"sendPost_4\">保险理赔部</label>" +
            "                </div>"+
            "<div class=\"radio-box\">" +
            "                    <input id='sendPost_5' type=\"radio\" name=\"sendPost\" value=\"市场部\">" +
            "                    <label for=\"sendPost_5\">市场部</label>" +
            "                </div>"+
            "<div class=\"radio-box\">" +
            "                    <input id='sendPost_6' type=\"radio\" name=\"sendPost\" value=\"其它\">" +
            "                    <label for=\"sendPost_6\">其它</label>" +
            "                </div>",
            btn:['确认','取消'],
            yes: function (index,layero) {
                //执行 Ajax 后重载
                $.ajax({
                    url : prefix+"/send/"+id+"?uid="+[[${member.id}]]+"&sendPost="+$('input[name="sendPost"]:checked').val(),
                    type : "post",
                    success : function(result) {
                        if(result.code==0){
                            return layer.msg('发券成功');
                        }
                        layer.close(index)
                    },
                    error:function () {
                        layer.msg('失败',{'icon':2});
                    }
                });
            },btn2: function (index,layero) {
            }
        })
    }
</script>
</body>
</html>